<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>立方体</title>
  <style>
    .box {
      width: 800px;
      height: 400px;
      margin: 50px auto;
      background-color:#000;
      overflow: hidden;
    }

    .cube {
      width: 300px;
      height: 300px;
      position: relative;
      margin: 50px auto;
      transform-style: preserve-3d;
      transform: rotateY(15deg) rotateX(20deg);
    }

    .cube > div {
      position: absolute;
      left: 0;
      top: 0;

      width: 100%;
      height: 100%;
      text-align: center;
      line-height: 300px;
      font-size: 18px;
      opacity: 0.6;
    }

    .cube .flat:first-child {
      background-color: pink;
      transform: translateZ(150px);
    }

    .cube .flat:nth-child(2) {
      background-color: red;
      transform: translateZ(-150px);
    }

    .cube .flat:nth-child(3) {
      background-color: orange;
      
      transform: rotateY(-90deg) translateZ(150px);
    }

    /* 右面 */
    .cube .flat:nth-child(4) {
      background-color: blue;

      transform: rotateY(90deg) translateZ(150px);
    }

    /* 上面 */
    .cube .flat:nth-child(5) {
      background-color: yellow;

      transform: rotateX(90deg) translateZ(150px);
    }

    .cube .flat:last-child {
      background-color:green;
      transform: rotateX(-90deg) translateZ(150px);
    }
  </style>
</head>
<body>

  <div class="box">
    <div class="cube">
      <div class="flat">前面</div>
      <div class="flat">后面</div>
      <div class="flat">左面</div>
      <div class="flat">右面</div>
      <div class="flat">上面</div>
      <div class="flat">下面</div>
    </div>
  </div>
</body>
</html>